import java.util.ArrayList;
import java.util.List;
import java.util.Random;

public class Game {
    public static final String[] SUITS = {"♥", "♠", "♦", "♣"};

    public List<Card> crateCards() {
        List<Card> cardsList = new ArrayList<>();

        for (int i = 0; i < SUITS.length; i++) {
            for (int j = 1; j <= 13; j++) {
                Card card = new Card(SUITS[i], j);
                cardsList.add(card);
            }
        }
        return cardsList;
    }

    public void shuffle(List<Card> cardsList) {//洗牌
        Random random = new Random();
        for (int i = cardsList.size() - 1; i > 0; i--) {
            int randIndex = random.nextInt(i);
            swap(cardsList, i, randIndex);
        }
    }

    public void swap(List<Card> cardsList, int i, int j) {
        Card tmp = cardsList.get(i);
        cardsList.set(i, cardsList.get(j));
        cardsList.set(j, tmp);
    }

    public List<List<Card>> play(List<Card> cardsList) {
        List<List<Card>> hand = new ArrayList<>();
        List<Card> hand0 = new ArrayList<>();
        List<Card> hand1 = new ArrayList<>();
        List<Card> hand2 = new ArrayList<>();

        hand.add(hand0);
        hand.add(hand1);
        hand.add(hand2);

        for (int i = 0; i < 5; i++) {
            for (int j = 0; j < 3; j++) {
                Card card = cardsList.remove(0);
                hand.get(j).add(card);
            }
        }
        return hand;
    }
}
